﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Patent.LJ;
using Patent.CN;
using System.Data;
using DevExpress.XtraCharts;
using System.Drawing;

public partial class China_Chart_OrientAreaPiesView : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string local =  Request["selected"];
        Patent.LJ.Topic topic = new Patent.LJ.Topic(Convert.ToInt32(Session["topicID"].ToString()));
        //Patent.Topic topic = new Topic(1);
        string localTable = topic.OriginalTable;//原产区表名

        if (string.IsNullOrEmpty(local))
        {
            Response.End();
            Response.Flush();
        }

        string[] area = local.Split(',');
        ChinaAnalysis ana = new ChinaAnalysis();
        DataTable dt = ana.GetLocalArea(area, localTable);
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            switch (dt.Columns[i].ColumnName)
            {
                case "dm": dt.Columns[i].ColumnName = "国省代码"; break;
                case "mc": dt.Columns[i].ColumnName = "国省名称"; break;
                case "sy": dt.Columns[i].ColumnName = "实用新型"; break;
                case "fm": dt.Columns[i].ColumnName = "发明专利"; break;
                case "wg": dt.Columns[i].ColumnName = "外观设计"; break;
                case "zj": dt.Columns[i].ColumnName = "总计"; break;
                default: break;
            }
        }

        Series syxxSeries = new Series("实用新型", ViewType.Pie);// WebChartCN.Series["实用新型"];
        Series fmzlSeries = new Series("发明专利", ViewType.Pie); //WebChartCN.Series["发明专利"];
        Series wgsjSeries = new Series("外观设计", ViewType.Pie);// WebChartCN.Series["外观设计"];
        WebChartCN.Series.Add(syxxSeries);
        WebChartCN.Series.Add(fmzlSeries);
        WebChartCN.Series.Add(wgsjSeries);

        syxxSeries.ValueDataMembers.AddRange(new string[] { "实用新型" });
        fmzlSeries.ValueDataMembers.AddRange(new string[] { "发明专利" });
        wgsjSeries.ValueDataMembers.AddRange(new string[] { "外观设计" });

        fmzlSeries.ShowInLegend = false;
        wgsjSeries.ShowInLegend = false;

        foreach (Series series in WebChartCN.Series)
        {
            series.DataSource = dt;
            series.ArgumentDataMember = "国省名称";
            series.ArgumentScaleType = ScaleType.Qualitative;
            series.ValueScaleType = ScaleType.Numerical;
            PieSeriesLabel pielabel = (PieSeriesLabel)series.Label;
            pielabel.Position = PieSeriesLabelPosition.Outside;
            pielabel.Border.Visible = false;
            
            pielabel.BackColor = Color.Transparent;
            pielabel.ColumnIndent = 20;
            pielabel.Antialiasing = false;
            PiePointOptions PointOptions =(PiePointOptions)series.PointOptions;
            PointOptions.PercentOptions.ValueAsPercent = false;
            PointOptions.ValueNumericOptions.Format = NumericFormat.FixedPoint;
            PointOptions.ValueNumericOptions.Precision = 0;
            series.PointOptions.PointView = PointView.ArgumentAndValues;
            series.LegendPointOptions.PointView = PointView.Argument;
            SeriesTitle title = new SeriesTitle();
            title.Text = series.Name;
            title.Font = new System.Drawing.Font("黑体", 14,FontStyle.Regular, GraphicsUnit.Point);
            ((PieSeriesView)series.View).Titles.Add(title) ;

        }
        // Prevent IE Cache
        Response.Expires = 0;
    }
}
